#include<stdio.h>
#include<math.h>
int main() {
    int number, temp_num, count, sum;
    scanf("%d", &number);
    if (number % 3) {
        printf("Error!\n");
        return 0;
    }
    sum = 0;
    count = 1;
    temp_num = number;
    while (temp_num) {
        sum += pow(temp_num % 10, 3);
        if (sum == 153)
            break;
        if (temp_num / 10)
            temp_num /= 10;
        else {
            temp_num = sum;
            count++;
            sum = 0;
        }
    }
    printf("count=%d\n", count);
    return 0;
}